#region Using References

using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.IO;

#endregion

namespace Beaker.Services.Interfaces
{
	/// <summary>
	/// Interface for abstracting IO Access
	/// </summary>
	[ContractClass( typeof( IOServiceContracts ) )]
	[Obsolete("switch to IFileSystemService")]
	public interface IIOService
	{
		/// <summary>
		/// Gets the path to the given special folder
		/// </summary>
		/// <param name="folder">The special folder to get the path for</param>
		/// <returns>The path to the given special folder</returns>
		string GetSpecialFolderPath( Environment.SpecialFolder folder );

		/// <summary>
		/// Get a list of the directories
		/// </summary>
		/// <param name="path">The path to search for directories.</param>
		/// <returns>A sequence of all the full directory names.</returns>
		IEnumerable<string> GetFolders( string path );

		/// <summary>
		/// Get a list of the files
		/// </summary>
		/// <param name="path">The path to search for files</param>
		/// <returns>A sequence of all the full file names.</returns>
		IEnumerable<string> GetFiles( string path );

		/// <summary>
		/// Get a list of the files
		/// </summary>
		/// <param name="path">The path to search for files</param>
		/// <param name="filter">The filter to filter the filers on.</param>
		/// <returns>
		/// A sequence of all the full file names.
		/// </returns>
		IEnumerable<string> GetFiles( string path, string filter );

		/// <summary>
		/// Get a list of the files
		/// </summary>
		/// <param name="path">The path to search for files</param>
		/// <param name="filter">The filter to filter the filers on.</param>
		/// <param name="searchOption">The search option.</param>
		/// <returns>
		/// A sequence of all the full file names.
		/// </returns>
		IEnumerable<string> GetFiles( string path, string filter, SearchOption searchOption );

		/// <summary>
		/// Check if the given file exists
		/// </summary>
		/// <param name="filePath">The path to the file to check.</param>
		/// <returns><c>true</c> when the file exists, otherwise <c>false</c>.</returns>
		bool FileExists( string filePath );

		/// <summary>
		/// Check if the given directory exists
		/// </summary>
		/// <param name="folderPath">The path to the directory to check.</param>
		/// <returns><c>true</c> when the directory exists, otherwise <c>false</c>.</returns>
		bool FolderExists( string folderPath );

		/// <summary>
		/// Open the file with the given path in read mode
		/// </summary>
		/// <param name="filePath">The path to the file to open.</param>
		/// <returns>The stream of the file.</returns>
		Stream FileOpenRead( string filePath );

		/// <summary>
		/// Open the text file with the given path in read mode
		/// </summary>
		/// <param name="filePath">The path to the file to open.</param>
		/// <returns>The TextReader of the file.</returns>
		TextReader FileOpenText( string filePath );
	}

	[ContractClassFor( typeof( IIOService ) )]
	public abstract class IOServiceContracts
		: IIOService
	{
		public string GetSpecialFolderPath( Environment.SpecialFolder folder )
		{
			Contract.Requires<ArgumentOutOfRangeException>( Enum.IsDefined( typeof( Environment.SpecialFolder ), folder ) );
			Contract.Ensures( Contract.Result<string>() != null );

			throw new NotImplementedException();
		}

		public IEnumerable<string> GetFolders( string path )
		{
			Contract.Requires<ArgumentNullException>( !string.IsNullOrEmpty( path ) );
			Contract.Ensures( Contract.Result<IEnumerable<string>>() != null );

			throw new NotImplementedException();
		}

		public IEnumerable<string> GetFiles( string path )
		{
			Contract.Requires<ArgumentNullException>( !string.IsNullOrEmpty( path ) );
			Contract.Ensures( Contract.Result<IEnumerable<string>>() != null );

			throw new NotImplementedException();
		}

		public IEnumerable<string> GetFiles( string path, string filter )
		{
			Contract.Requires<ArgumentNullException>( !string.IsNullOrEmpty( path ) );
			Contract.Ensures( Contract.Result<IEnumerable<string>>() != null );

			throw new NotImplementedException();
		}

		public IEnumerable<string> GetFiles( string path, string filter, SearchOption searchOption )
		{
			Contract.Requires<ArgumentNullException>( !string.IsNullOrEmpty( path ) );
			Contract.Requires<ArgumentOutOfRangeException>( Enum.IsDefined( typeof( SearchOption ), searchOption ) );
			Contract.Ensures( Contract.Result<IEnumerable<string>>() != null );

			throw new NotImplementedException();
		}

		public bool FileExists( string filePath )
		{
			Contract.Requires<ArgumentNullException>( !string.IsNullOrEmpty( filePath ) );

			throw new NotImplementedException();
		}

		public bool FolderExists( string folderPath )
		{
			Contract.Requires<ArgumentNullException>( !string.IsNullOrEmpty( folderPath ) );

			throw new NotImplementedException();
		}

		public Stream FileOpenRead( string filePath )
		{
			Contract.Requires<ArgumentNullException>( !string.IsNullOrEmpty( filePath ) );
			Contract.Ensures( Contract.Result<Stream>() != null );

			throw new NotImplementedException();
		}

		public TextReader FileOpenText( string filePath )
		{
			Contract.Requires<ArgumentNullException>( !string.IsNullOrEmpty( filePath ) );
			Contract.Ensures( Contract.Result<TextReader>() != null );

			throw new NotImplementedException();
		}
	}
}